# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from pydantic import BaseModel, Field
from fastapi import Query


class DrawConfigIn(BaseModel):
    engine: str = Query(..., pattern=r"^(mj|sd|doubao|dalle)$", description="绘图引擎")


class DrawGenerateIn(BaseModel):
    """ 绘画生成参数"""
    engine: str = Field(..., pattern=r"^(mj|sd|doubao|dalle)$", description="绘图引擎")
    action: str = Field(default="generate", description="绘图动作: [generate=生成,upscale=放大,variation=变换]")
    model: str = Field(default="", description="绘图模型")
    scale: str = Field(default="", description="绘图比例")
    version: str = Field(default="", max_length=250, description="版本参数")
    image_id: str = Field(default="", max_length=250, description="图像ID")
    image_ref: str = Field(default="", max_length=250, description="参考图片")
    prompt_in: str = Field(min_length=1, max_length=65535, description="原始提示词")
    prompt_en: str = Field(default="", max_length=65535, description="英文提示词")
    other_params: dict = Field(default={}, description="其它参数")
    complex_params: dict = Field(default={}, description="高级参数")

    class Config:
        json_schema_extra = {
            "example": {
                "engine": "mj",
                "action": "generate",
                "model": "mj",
                "scale": "1:1",
                "prompt_in": "tt",
                "prompt_en": "",
                "version": "6.1",
                "image_id": "",
                "image_ref": "",
                "other_params": {
                    "mode": "relax",
                    "style": "",
                    "quality": "1"
                },
                "complex_params": {
                    "seed": "",
                    "iw": 1,
                    "q": 1,
                    "s": 100,
                    "c": 0
                }
            }
        }

    @classmethod
    def messages(cls):
        return {
            "prompt_in.min_length": "请填写文本描述"
        }
